import { Controller, Headers, Get } from '@nestjs/common';
import { getResponse, ERROR_CODE, ERROR_MESSAGE } from 'src/common/const/const';
import { AuthService } from 'src/services/Auth';
import { GoodsService } from './goods.service';

@Controller('goods')
export class GoodsController {
    constructor(
        private readonly goodsService: GoodsService,
        private readonly authService: AuthService
    ) { }

    // 获取所有商品
    @Get('/findAll')
    async findAllGoods(@Headers() headers: any) {
        const userInfo = this.authService.checkAuth(headers);
        if (!userInfo) {
            return getResponse(ERROR_CODE.VERIFY_EXPIRE, ERROR_MESSAGE[ERROR_CODE.VERIFY_EXPIRE], {})
        }
        let response = await this.goodsService.findAllGoods();
        return getResponse(0, "success", response);
    }
}
